<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<title>提现记录列表</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="/resources/css/base.css" rel="stylesheet"
	type="text/css" />
<link href="/resources/js/miniui/themes/default/miniui.css"
	rel="stylesheet" type="text/css" />
<script src="/resources/js/jquery-1.6.2.min.js"
	type="text/javascript"></script>
<script src="/resources/js/miniui/miniui.js"
	type="text/javascript"></script>
<script src="/resources/js/ckeditor/ckeditor.js"
	type="text/javascript"></script>
<script src="/resources/js/statusUtil.js" type="text/javascript"></script>
<script src="/resources/js/wbkDate.js" type="text/javascript"></script>
<style type="text/css">
.errorText {
	color: red;
}
.td1 {
	width: 20%;
	text-align: right;
}

.td2 {
	width: 30%;
	text-align: left;
}

.td3 {
	width: 12%;
	text-align: right;
}

.td4 {
	width: 38%;
	text-align: left;
}
</style>
</head>
<body>
	<h1>提现记录列表</h1>
	<input id="step" type="hidden" value="${step}">
	<c:if test="${not empty step }">
		<c:if test="${'1' eq step }">
			<div style="padding-top: 5px; padding-bottom: 5px; width: 95%;">
				<a class="mini-button"
						img="/resources/js/miniui/themes/icons/edit.gif"
						onclick="editRow()">修改状态</a>
			</div>
		</c:if>
	</c:if>
	
	<div style="padding-top: 5px; padding-bottom: 5px; width: 95%;">
		<span>用户手机号：</span><input type="text" id="search_phone" />
		<c:if test="${empty step}">
			<span>状态：</span><input id="search_type_info" class="mini-combobox" valueField="data" textField="data"
						valueFromSelect="true" url="/withdraw/getStateJson" />
		</c:if>
		<input type="button" value="查找" onclick="search()" />
	</div>
	<div id="mini-datagrid" class="mini-datagrid"
		style="width: 95%; height: 400px;"
		url="/withdraw/selectByPage" pageSize="20" idField="id"
		allowResize="true">

		<div property="columns">
			<div type="indexcolumn">序号</div>
			<div type="checkcolumn">选择</div>
			<div field="uid">用户ID</div>
			<div field="realname">姓名</div>
			<div field="phone">手机号</div>
			<div field="money">金额（元）</div>
			<div field="bankcard">银行卡</div>
			<div field="bankName">开户行</div>
			<div field="state">状态</div>
			<div field="createTime" renderer="tipTimeRen">发布时间</div>
		</div>
	</div>
	
	<!-- 修改状态 -->
	<div id="editWindow" class="mini-window" title="修改状态"
		style="width: 400px;" showModal="true" allowResize="true"
		allowDrag="true">
		<div id="editform" class="form">
			<input class="mini-hidden" name="id" value="0" />
			<table style="width: 100%; text-align: center;">
				<tr>
					<td class="td1">审核状态：</td>
					<!-- <td class="td2"><input name="state"
						class="mini-combobox" valueField="data" textField="data"
						valueFromSelect="true" url="/withdraw/getStateJson"/></td> -->
					<td class="td2">
						<select id="status">
							
						</select>
					</td>
				</tr>
				<tr>
					<td
						style="text-align: center; padding-top: 5px; padding-right: 20px;"
						colspan="3"><a class="mini-button"
						img="/resources/js/miniui/themes/icons/save.gif"
						onclick="saveRow()">保存</a> <a class="mini-button"
						img="/resources/js/miniui/themes/icons/cancel.gif"
						onclick="cancelRow()">取消</a></td>
				</tr>
			</table>
		</div>
	</div>
</body>
<script type="text/javascript">
	var step = $("#step").val();
	mini.parse();
	var datagrid = mini.get("mini-datagrid");
	var editWindow = mini.get("editWindow");
	datagrid.load({
		step:step
	});
	
	var form = new mini.Form("editform");
	
	function search(){
		datagrid.load({phone : $('#search_phone').val(),
				state : mini.get("#search_type_info").getValue()});
	}

	function editRow() {
		
		var node = datagrid.getSelected();
		if (node) {
			editWindow.show();
			form.clear();
			//form.setData(node);
			
			$.ajax({
				url : "/withdraw/getNowState" ,
				data : {id:node.id},
				type : "post",
				dataType : "json",
				success : function(data) {
					var htmlStr = "";
					$.each(data, function(i, n){
						htmlStr += '<option value="">'+n.data+'</option>';
					});
					$("#status").html(htmlStr);
				},
				error : function(jqXHR, textStatus, errorThrown) {
					alert(jqXHR.responseText);
				}
			});
		} else {
			mini.alert("请选择一条!");
		}
	}
	
	function saveRow() {
		var node = datagrid.getSelected();
		var json = {
			"id":node.id,
			"state":$("#status").find("option:selected").text()
		};
		$.ajax({
			url : "/withdraw/update" ,
			data : json,
			type : "post",
			dataType : "json",
			success : function(data) {
				if(data.code == 0){
					editWindow.hide();
					datagrid.reload();
					mini.alert("操作成功!");
				}else{
					mini.alert(data.data);
				}
			},
			error : function(jqXHR, textStatus, errorThrown) {
				alert(jqXHR.responseText);
			}
		});

	}
	
	function cancelRow() {
		datagrid.reload();
		editWindow.hide();
	}
</script>

</html>
